<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jackysoft.mapper.${entityName}Mapper">
   
   <select id="count" resultType="int">
       select count(*) from ${entityName};
   </select>
   
   <select id="countQuery" resultType="int">
       select count(*) from ${entityName} ${'$'}{query.sqlQuery};
   </select>
   
   <update id="doOrder" >       
       update ${entityName} set sort=${'$'}{sort} where id=${'#'}{id};           
   </update>
   
   <select id="findAll" resultType="${entityName?uncap_first}">
       select * from ${entityName};
   </select>
   
   <select id="findOne" resultType="${entityName?uncap_first}">
       select * from ${entityName}  where id=${'#'}{id};
   </select>
      
   <insert id="insert" resultType="int">
       insert into ${entityName} (${'$'}{bean.sqlInsertMeta.field}) values(${'#'}{bean.sqlInsertMeta.value});
   </insert>
     
   
   <select id="pager"  resultType="${entityName?uncap_first}">
       select * from ${entityName} limit ${'$'}{start},${'$'}{rows};
   </select>
   
   <select id="query"  resultType="${entityName?uncap_first}">
       select * from ${entityName} ${'$'}{query.sqlQuery};
   </select>
   
   <select id="queryOne"  resultType="${entityName?uncap_first}">
       select * from ${entityName} ${'$'}{query.sqlQuery} limit 1;
   </select>
   
   <select id="queryPager" resultType="${entityName?uncap_first}">
        select * from ${entityName} ${'$'}{query.sqlQuery} limit ${'$'}{start},${'$'}{rows};;
   </select>
   
   <select id="querySortPager" resultType="${entityName?uncap_first}">
        select * from ${entityName} ${'$'}{query.sqlQuery}  ${'$'}{sort.order} limit ${'$'}{start},${'$'}{rows};;
   </select>
   
   <delete id="removeAll">
        delete from ${entityName};
   </delete>
   
   <delete id="remove">
        delete from ${entityName} where id=${'#'}{id};
   </delete>
   
   <delete id="removeQuery">
        delete from ${entityName} ${'$'}{query.sqlQuery};
   </delete>
  
   <update id="update">
        update ${entityName} set ${'$'}{bean.sqlUpdateMeta} where id=${'#'}{bean.id};
   </update>
   
   <update id="updateQuery">
        update ${entityName} set ${'$'}{bean.sqlUpdateMeta} ${'$'}{query.sqlQuery} ;
   </update>
   
</mapper>